package prictice.visits;

import org.apache.storm.Config;
import org.apache.storm.LocalCluster;
import org.apache.storm.StormSubmitter;
import org.apache.storm.generated.AlreadyAliveException;
import org.apache.storm.generated.AuthorizationException;
import org.apache.storm.generated.InvalidTopologyException;
import org.apache.storm.topology.TopologyBuilder;
import prictice.base.SourceSpout;
import prictice.lesson.MySpout;

/**
 * @Package prictice.lesson
 * @Description:
 * @Author elwyn
 * @Date 2017/9/15 0:26
 * @Email elonyong@163.com
 */
public class PvTopo {
    public static void main(String[] args) throws Exception {
        TopologyBuilder topologyBuilder = new TopologyBuilder();
        topologyBuilder.setSpout("spout", new SourceSpout(), 1);
        topologyBuilder.setBolt("bolt", new PVBolt(), 4).shuffleGrouping("spout");

        Config config = new Config();
        config.setDebug(true);
        if (args.length > 0) {
            try {
                StormSubmitter.submitTopology(args[0], config, topologyBuilder.createTopology());
            } catch (AlreadyAliveException | InvalidTopologyException | AuthorizationException e) {
                e.printStackTrace();
            }
        } else {
            LocalCluster localCluster = new LocalCluster();
            localCluster.submitTopology("mytopology", config, topologyBuilder.createTopology());
        }
    }
}
